package com.lykj.modules.shop.wrapper;

import com.lykj.core.mp.support.BaseEntityWrapper;
import com.lykj.core.tool.node.ForestNodeMerger;
import com.lykj.core.tool.utils.BeanUtil;
import com.lykj.modules.shop.entity.StoreCategory;
import com.lykj.modules.shop.vo.StoreCategoryVO;

import java.util.List;
import java.util.Objects;

/**
 * 商品分类表包装类,返回视图层所需的字段
 *
 * @author cxl
 * @since 2022-01-13
 */
public class StoreCategoryWrapper extends BaseEntityWrapper<StoreCategory, StoreCategoryVO> {

	public static StoreCategoryWrapper build() {
		return new StoreCategoryWrapper();
	}

	@Override
	public StoreCategoryVO entityVO(StoreCategory storeCategory) {
		StoreCategoryVO storeCategoryVO = Objects.requireNonNull(BeanUtil.copy(storeCategory, StoreCategoryVO.class));

		//User createUser = UserCache.getUser(storeCategory.getCreateUser());
		//User updateUser = UserCache.getUser(storeCategory.getUpdateUser());
		//storeCategoryVO.setCreateUserName(createUser.getName());
		//storeCategoryVO.setUpdateUserName(updateUser.getName());

		return storeCategoryVO;
	}

	public List<StoreCategoryVO> listNodeLazyVO(List<StoreCategoryVO> list) {
		return ForestNodeMerger.merge(list);
	}
}
